package scr;

import java.util.Scanner;

public class supermarket {
    public static void main(String[] args) {
        double toothbrush=8.8;      //牙刷价格
        double towel=10.0;      //毛巾价格
        double cup=10.0;      //水杯价格
        double apple=18.8;      //苹果价格
        double banana=15.5;     //香蕉价格
        int i=0;
        String a="Y";
        System.out.println("---------多多买菜---------");
        System.out.println("1.牙刷的价格为："+toothbrush+"元");
        System.out.println("2.毛巾的价格为: "+towel+"元");
        System.out.println("3.水杯的价格为："+cup+"元");
        System.out.println("4.苹果的价格为"+apple+"元");
        System.out.println("5.香蕉的价格为:"+banana+"元");
        while (a.equals("Y"))   {
            Scanner scl = new Scanner(System.in);
            System.out.println("请输入你需要购买商品的序列号：");
            i=scl.nextInt();
            switch (i){
                case 1:
                    System.out.println("请输入你需要购买牙刷的数量：");
                    int toothbrushNumber= scl.nextInt();
                    double toohbrushNum=toothbrushNumber*toothbrush;
                    System.out.println("你购买了牙刷"+toothbrushNumber+"支，需要花费"+toohbrushNum+"元");
                    System.out.println("需要继续购买请输入Y，否则输入N ");
                    a=scl.next();
                    break;
                    case 2:
                        System.out.println("请输入你需要购买毛巾的数量：");
                        int towelNumber=scl.nextInt();
                        double towelNum=towelNumber*towel;
                        System.out.println("你购买了毛巾"+towelNumber+"个,需要花费"+towelNum+"元");
                        System.out.println("需要继续购买请输入Y,否则输入N");
                        a=scl.next();
                        break;
                        case 3:
                            System.out.println("请输入你需要购买水杯的数量：");
                            int cupNumber= scl.nextInt();
                            double cupNum=cupNumber*cup;
                            System.out.println("你购买了水杯"+cupNumber+"个，需要花费"+cupNum+"元");
                            System.out.println("需要继续购买请输入Y,否则输入N");
                            a=scl.next();
                            break;
                        case 4:
                        System.out.println("请输入你需要购买苹果的数量：");
                        int appleNumber= scl.nextInt();
                        double appleNum=appleNumber*apple;
                        System.out.println("你购买了水杯"+appleNumber+"个，需要花费"+appleNum+"元");
                        System.out.println("需要继续购买请输入Y,否则输入N");
                        a=scl.next();
                        break;
                case 5:
                    System.out.println("请输入你需要购买香蕉的数量：");
                    int banananumber= scl.nextInt();
                    double banananum=banananumber*banana;
                    System.out.println("你购买了水杯"+banananumber+"个，需要花费"+banananum+"元");
                    System.out.println("需要继续购买请输入Y,否则输入N");
                    a=scl.next();
                    break;
            }
        }
        System.out.println("期待您的下次光临！");
    }
}
